﻿<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>OSSJK 2.0</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Cache-Control" content="no-siteapp">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="static/css/index.css" media="all" />
</head>
<body class="main_body">
	<div class="layui-layout layui-layout-admin">
		<!-- 顶部 -->
		<div class="layui-header header">
			<div class="layui-main mag0">
				<a href="#" class="logo">OSSJK 2.0</a>
				<!-- 显示/隐藏菜单 -->
				<a href="javascript:;" class="seraph hideMenu icon-caidan"></a>
				<!-- 顶部右侧菜单 -->
				<ul class="layui-nav top_menu">
					<li class="layui-nav-item" pc><a data-url="page/advisory/customer/listFollow.html" href="javascript:;" class="follow"><i class="layui-icon">&#xe60e;</i><cite>今天跟进</cite><span class="layui-badge">99</span></a></li>
					<li class="layui-nav-item" pc><a href="javascript:;" class="clearCache"><i class="layui-icon" data-icon="&#xe640;">&#xe640;</i><cite>清除缓存</cite><span class="layui-badge-dot"></span></a></li>
					<li class="layui-nav-item lockcms" pc><a href="javascript:;"><i class="seraph icon-lock"></i><cite>锁屏</cite></a></li>
					<li class="layui-nav-item" id="userInfo"><a href="javascript:;"> <!--<img src="images/face.jpg" class="layui-nav-img userAvatar" width="35" height="35">--> <cite class="adminName"></cite>
					</a>
						<dl class="layui-nav-child">
							<!-- <dd>
								<a href="javascript:;" class="updatePwd" data-url=""><i class="seraph icon-xiugai" data-icon="icon-xiugai"></i><cite>修改密码</cite></a>
							</dd> -->
							<dd>
								<a href="javascript:;" class="updatePwd"><i class="seraph icon-xiugai" data-icon="icon-xiugai"></i><cite>修改密码</cite></a>
							</dd>
							<dd>
								<a href="javascript:;" class="signOut"><i class="seraph icon-tuichu"></i><cite>退出</cite></a>
							</dd>
						</dl></li>
				</ul>
			</div>
		</div>
		<!-- 左侧导航 -->
		<div class="layui-side layui-bg-black">
			<!-- <div class="user-photo">
                <a class="img" title="我的头像" ><img src="images/face.jpg" class="userAvatar"></a>
                <p>你好！<span class="userName">驊驊龔頾</span>, 欢迎登录</p>
            </div>
            搜索
            <div class="layui-form component">
                <select name="search" id="search" lay-search lay-filter="searchPage">
                    <option value="">搜索页面或功能</option>
                    <option value="1">layer</option>
                    <option value="2">form</option>
                </select>
                <i class="layui-icon">&#xe615;</i>
            </div> -->
			<div class="navBar layui-side-scroll" id="navBar">
				<ul class="layui-nav layui-nav-tree">
					<li class="layui-nav-item layui-this"><a href="javascript:;" data-url="page/main.html"><i class="layui-icon" data-icon=""></i> <cite>后台首页</cite></a></li>
					<!-- <li class="layui-nav-item"><a><i class="layui-icon" data-icon=""></i><cite>系统管理</cite><span class="layui-nav-more"></span> </a>
						<dl class="layui-nav-child">
							<dd>
								<a data-url="page/system/employee/list.html"><i class="layui-icon" data-icon=""></i><cite>员工管理</cite></a>
							</dd>
							<dd>
								<a data-url="page/system/department/list.html"><i class="layui-icon" data-icon=""></i><cite>部门管理</cite></a>
							</dd>
							<dd>
								<a data-url="page/system/post/list.html"><i class="layui-icon" data-icon=""></i><cite>岗位管理</cite></a>
							</dd>
							<dd>
								<a data-url="page/system/permission/list.html"><i class="layui-icon" data-icon=""></i><cite>权限管理</cite></a>
							</dd>
							<dd>
								<a data-url="page/system/dictionary/list.html"><i class="layui-icon" data-icon=""></i><cite>自定义属性</cite></a>
							</dd>
							<dd>
								<a data-url="page/system/attribute/list.html"><i class="layui-icon" data-icon=""></i><cite>系统属性</cite></a>
							</dd>
							<dd>
                           		<a data-url="page/system/employee/updateDetail.html"><i class="layui-icon" data-icon=""></i><cite>用户注册</cite></a>
                       		</dd>
                      		 
						</dl></li>
					<li data-name="component" class="layui-nav-item "><a href="javascript:;" lay-tips="组件" lay-direction="2"> <i class="layui-icon layui-icon-component"></i> <cite>组件</cite> <span class="layui-nav-more"></span></a>
						<dl class="layui-nav-child">
							<dd data-name="grid">
								<a href="javascript:;">栅格<span class="layui-nav-more"></span></a>
								<dl class="layui-nav-child">
									<dd data-name="list">
										<a lay-href="component/grid/list.html">等比例列表排列</a>
									</dd>
									<dd data-name="mobile">
										<a lay-href="component/grid/mobile.html">按移动端排列</a>
									</dd>
								</dl>
							</dd>
							<dd data-name="button">
								<a lay-href="component/button/index.html">按钮</a>
							</dd>
						</dl></li> -->
				</ul>
			</div>
		</div>
		<!-- 右侧内容 -->
		<div class="layui-body layui-form">
			<div class="layui-tab mag0" lay-filter="bodyTab" id="top_tabs_box">
				<ul class="layui-tab-title top_tab" id="top_tabs">
					<li class="layui-this" lay-id=""><i class="layui-icon">&#xe68e;</i> <cite>后台首页</cite></li>
				</ul>
				<ul class="layui-nav closeBox">
					<li class="layui-nav-item"><a href="javascript:;"><i class="layui-icon caozuo">&#xe643;</i> 页面操作</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="javascript:;" class="refresh refreshThis"><i class="layui-icon">&#x1002;</i> 刷新当前</a>
							</dd>
							<dd>
								<a href="javascript:;" class="closePageOther"><i class="seraph icon-prohibit"></i> 关闭其他</a>
							</dd>
							<dd>
								<a href="javascript:;" class="closePageAll"><i class="seraph icon-guanbi"></i> 关闭全部</a>
							</dd>
						</dl></li>
				</ul>
				<div class="layui-tab-content clildFrame">
					<div class="layui-tab-item layui-show">
						<iframe src="page/main.html"></iframe>
					</div>
				</div>
			</div>
		</div>
		<!-- 底部 -->
		<div class="layui-footer footer">
			<p>
				<span class="footer-span">copyright @2018 OSSJK</span>
			</p>
		</div>
	</div>

	<!-- 移动导航 -->
	<div class="site-tree-mobile">
		<i class="layui-icon">&#xe602;</i>
	</div>
	<div class="site-mobile-shade"></div>
	<script type="text/javascript" src="static/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="static/layui/layui.js"></script>
	<script type="text/javascript" src="static/js/index.js"></script>
	<script type="text/javascript" src="static/custom/js/common.js"></script>
	<script type="text/javascript">
		layui.use(["element", 'form', 'layer' ], function() {
			var layer = parent.layer === undefined ? layui.layer : parent.layer;
			var $ = layui.jquery;
			var getInfoApi = "getInfo";
			var logoutApi = "logout";
			var getFollowCountApi = "getFollowCount";
			var element = layui.element;
			//过滤权限
			function filterMenu(permissions) {
				if (permissions) {
					var permissionCodeArray =new Array();
					var menuTree=new Array();
					for (permission of  permissions) {
						if(permission.type != 1){
							//类型 1-显示菜单、2-跳转菜单、3-功能按钮
							//把权限码放到数组当中
							permissionCodeArray.push(permission.code);
						}else{
							getTree(permission,permissions);
							menuTree.push(permission);
						}
					}
					//加载菜单
					$(".layui-nav-tree").append(initMenu(menuTree));
					element.init();
					//存放缓存
					cache.code.set(permissionCodeArray);
				}
			}
			

	        //根据菜单主键id生成菜单列表html
	        //id：菜单主键id
	        //arry：菜单数组信息
	        function getTree(permission,permissions) {
	        	permission["child"]=new Array();
	        	for (child of  permissions) {
	        		if(child.pid){
	        			if(child.pid==permission.id &&  child.type !=3){
	        				permission.child.push(child);
		        			getTree(child,permissions);
		        		}
	        		}
	        	}
	        }
			
	        function initMenu(permissions){
	        	var str="";
	        	for (permission of  permissions) {
	        		str +='<li class="layui-nav-item"><a><i class="layui-icon '+ permission.icon + '"></i><cite>'+permission.name+'</cite><span class="layui-nav-more"></span> </a>';
	        		str +=appendChild(permission);
	        		str +='</li>';
	        	}
	        	return str;
	        }
	        
	        function appendChild( permission){
	        	var str="";
	        	if(permission.child){
		        	str +='<dl class="layui-nav-child">';
			        	for (child  of permission.child) {
			        		str +='<dd>';
			        		str +='<a data-url="'+child.url+'"><i class="layui-icon '+ child.icon + '"></i><cite>'+child.name+'</cite></a>';
			        		str +='</dd>';
	    				}
					str +='</dl>';
	        	}
	        	return str;
	        }
	        
	        if(cache.attribute.get()){
	        	var attribute = JSON.parse(cache.attribute.get());
	        	$(".footer-span").html(attribute.systembottom);
	        	$(".logo").html(attribute.systemname);
	        }
			//加载用户信息 
			if(cache.user.get() &&  cache.permission.get()){
				var user=JSON.parse(cache.user.get()) ;  
				$(".adminName").html(user.name);
				var permission=JSON.parse(cache.permission.get()) ;  
				filterMenu(permission);
			}else{
				loadAjax( getInfoApi, "get", null, function(response) {
					baseCallBack(response, function(response) {
						baseCallBack(response, function(response) {
							//响应设置用户信息
							$(".adminName").html(response.data.user.name);
							//获取权限
							filterMenu(response.data.permission);
							cache.user.set(JSON.stringify(response.data.user));
							cache.permission.set(JSON.stringify(response.data.permission));
							cache.dsub.set(JSON.stringify(response.data.dsub));
							cache.psub.set(JSON.stringify(response.data.psub));
							cache.did.set(response.data.did);
							cache.pid.set(response.data.pid);
						})
					});
				});
			}
			
			//今日跟进数量
			loadAjax( getFollowCountApi, "get", null, function(response) {
				baseCallBack(response, function(response) {
					baseCallBack(response, function(response) {
						$(".layui-badge").html(response.data);
					})
				});
			});
			
			 

			$(".signOut").click(function() {
				confirmLayer('提示信息', '确定退出？', function(confirm, index) {
					loadAjax( logoutApi, "get", null, function(response) {
						baseCallBack(response, function(response) {
							cache.cleanAll();
							location.href = "./toLogin"
						})
					});
				})
			});
		});
	</script>
</body>
</html>